home *** CD-ROM | disk | FTP | other *** search
/ PC/CD Gamer UK 120 / CD Gamer Issue 120 (March 2003) (Disc 2).ISO / mods / Q2_Codered / codeRED1_0.exe / Data1.cab / g_monster.c1 < prev    next >
Encoding:
Text File  |  2002-12-07  |  18.1 KB  |  750 lines

  1. #include "g_local.h"
  2.  
  3.  
  4. //
  5. // monster weapons
  6. //
  7.  
  8. //FIXME mosnters should call these with a totally accurate direction
  9. // and we can mess it up based on skill.  Spread should be for normal
  10. // and we can tighten or loosen based on skill.  We could muck with
  11. // the damages too, but I'm not sure that's such a good idea.
  12. void monster_fire_bullet (edict_t *self, vec3_t start, vec3_t dir, int damage, int kick, int hspread, int vspread, int flashtype)
  13. {
  14.     fire_bullet (self, start, dir, damage, kick, hspread, vspread, MOD_UNKNOWN);
  15.  
  16.     gi.WriteByte (svc_muzzleflash2);
  17.     gi.WriteShort (self - g_edicts);
  18.     gi.WriteByte (flashtype);
  19.     gi.multicast (start, MULTICAST_PVS);
  20. }
  21.  
  22. void monster_fire_shotgun (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int hspread, int vspread, int count, int flashtype)
  23. {
  24.     fire_shotgun (self, start, aimdir, damage, kick, hspread, vspread, count, MOD_UNKNOWN);
  25.  
  26.     gi.WriteByte (svc_muzzleflash2);
  27.     gi.WriteShort (self - g_edicts);
  28.     gi.WriteByte (flashtype);
  29.     gi.multicast (start, MULTICAST_PVS);
  30. }
  31.  
  32. void monster_fire_blaster (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int flashtype, int effect)
  33. {
  34.     fire_blaster (self, start, dir, damage, speed, effect, false);
  35.  
  36.     gi.WriteByte (svc_muzzleflash2);
  37.     gi.WriteShort (self - g_edicts);
  38.     gi.WriteByte (flashtype);
  39.     gi.multicast (start, MULTICAST_PVS);
  40. }    
  41.  
  42. void monster_fire_grenade (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, int flashtype)
  43. {
  44.     fire_grenade (self, start, aimdir, damage, speed, 2.5, damage+40);
  45.  
  46.     gi.WriteByte (svc_muzzleflash2);
  47.     gi.WriteShort (self - g_edicts);
  48.     gi.WriteByte (flashtype);
  49.     gi.multicast (start, MULTICAST_PVS);
  50. }
  51.  
  52. void monster_fire_rocket (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int flashtype)
  53. {
  54.     fire_rocket (self, start, dir, damage, speed, damage+20, damage);
  55.  
  56.     gi.WriteByte (svc_muzzleflash2);
  57.     gi.WriteShort (self - g_edicts);
  58.     gi.WriteByte (flashtype);
  59.     gi.multicast (start, MULTICAST_PVS);
  60. }
  61.     
  62. void monster_fire_stinger (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int flashtype)
  63. {
  64.     fire_stinger2 (self, start, dir, damage, speed, damage+20, damage);
  65.  
  66.     gi.WriteByte (svc_muzzleflash2);
  67.     gi.WriteShort (self - g_edicts);
  68.     gi.WriteByte (flashtype);
  69.     gi.multicast (start, MULTICAST_PVS);
  70. }
  71.     
  72. void monster_fire_railgun (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int flashtype)
  73. {
  74.     fire_rail (self, start, aimdir, damage, kick);
  75.  
  76.     gi.WriteByte (svc_muzzleflash2);
  77.     gi.WriteShort (self - g_edicts);
  78.     gi.WriteByte (flashtype);
  79.     gi.multicast (start, MULTICAST_PVS);
  80. }
  81.  
  82. void monster_fire_sidewinder (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int flashtype)
  83. {
  84.     fire_sidewinder2 (self, start, dir, damage, speed, damage+20, damage);
  85.  
  86.     gi.WriteByte (svc_muzzleflash2);
  87.     gi.WriteShort (self - g_edicts);
  88.     gi.WriteByte (flashtype);
  89.     gi.multicast (start, MULTICAST_PVS);
  90. }
  91.  
  92. void monster_fire_bfg (edict_t *self, vec3_t start, vec3_t aimdir, int damage, int speed, int kick, float damage_radius, int flashtype)
  93. {
  94.     fire_bfg (self, start, aimdir, damage, speed, damage_radius);
  95.  
  96.     gi.WriteByte (svc_muzzleflash2);
  97.     gi.WriteShort (self - g_edicts);
  98.     gi.WriteByte (flashtype);
  99.     gi.multicast (start, MULTICAST_PVS);
  100. }
  101.  
  102. void monster_fire_floater (edict_t *self, vec3_t start, vec3_t dir, int damage, int speed, int flashtype)
  103. {
  104.     fire_floater_alien (self, start, dir, damage, speed, 120, 120, 8);
  105.     
  106.     gi.WriteByte (svc_muzzleflash2);
  107.     gi.WriteShort (self - g_edicts);
  108.     gi.WriteByte (flashtype);
  109.     gi.multicast (start, MULTICAST_PVS);
  110. }
  111.  
  112. //
  113. // Monster utility functions
  114. //
  115.  
  116. static void M_FliesOff (edict_t *self)
  117. {
  118.     self->s.effects &= ~EF_FLIES;
  119.     self->s.sound = 0;
  120. }
  121.  
  122. static void M_FliesOn (edict_t *self)
  123. {
  124.     if (self->waterlevel)
  125.         return;
  126.     self->s.effects |= EF_FLIES;
  127.     self->s.sound = gi.soundindex ("infantry/inflies1.wav");
  128.     self->think = M_FliesOff;
  129.     self->nextthink = level.time + 60;
  130. }
  131.  
  132. void M_FlyCheck (edict_t *self)
  133. {
  134.     if (self->waterlevel)
  135.         return;
  136.  
  137.     if (random() > 0.5)
  138.         return;
  139.  
  140.     self->think = M_FliesOn;
  141.     self->nextthink = level.time + 5 + 10 * random();
  142. }
  143.  
  144. void AttackFinished (edict_t *self, float time)
  145. {
  146.     self->monsterinfo.attack_finished = level.time + time;
  147. }
  148.  
  149.  
  150. void M_CheckGround (edict_t *ent)
  151. {
  152.     vec3_t        point;
  153.     trace_t        trace;
  154.  
  155.     if (ent->flags & (FL_SWIM|FL_FLY))
  156.         return;
  157.  
  158.     if (ent->velocity[2] > 100)
  159.     {
  160.         ent->groundentity = NULL;
  161.         return;
  162.     }
  163.  
  164. // if the hull point one-quarter unit down is solid the entity is on ground
  165.     point[0] = ent->s.origin[0];
  166.     point[1] = ent->s.origin[1];
  167.     point[2] = ent->s.origin[2] - 0.25;
  168.  
  169.     trace = gi.trace (ent->s.origin, ent->mins, ent->maxs, point, ent, MASK_MONSTERSOLID);
  170.  
  171.     // check steepness
  172.     if ( trace.plane.normal[2] < 0.7 && !trace.startsolid)
  173.     {
  174.         ent->groundentity = NULL;
  175.         return;
  176.     }
  177.  
  178. //    ent->groundentity = trace.ent;
  179. //    ent->groundentity_linkcount = trace.ent->linkcount;
  180. //    if (!trace.startsolid && !trace.allsolid)
  181. //        VectorCopy (trace.endpos, ent->s.origin);
  182.     if (!trace.startsolid && !trace.allsolid)
  183.     {
  184.         VectorCopy (trace.endpos, ent->s.origin);
  185.         ent->groundentity = trace.ent;
  186.         ent->groundentity_linkcount = trace.ent->linkcount;
  187.         ent->velocity[2] = 0;
  188.     }
  189. }
  190.  
  191.  
  192. void M_CatagorizePosition (edict_t *ent)
  193. {
  194.     vec3_t        point;
  195.     int            cont;
  196.  
  197. //
  198. // get waterlevel
  199. //
  200.     point[0] = ent->s.origin[0];
  201.     point[1] = ent->s.origin[1];
  202.     point[2] = ent->s.origin[2] + ent->mins[2] + 1;    
  203.     cont = gi.pointcontents (point);
  204.  
  205.     if (!(cont & MASK_WATER))
  206.     {
  207.         ent->waterlevel = 0;
  208.         ent->watertype = 0;
  209.         return;
  210.     }
  211.  
  212.     ent->watertype = cont;
  213.     ent->waterlevel = 1;
  214.     point[2] += 26;
  215.     cont = gi.pointcontents (point);
  216.     if (!(cont & MASK_WATER))
  217.         return;
  218.  
  219.     ent->waterlevel = 2;
  220.     point[2] += 22;
  221.     cont = gi.pointcontents (point);
  222.     if (cont & MASK_WATER)
  223.         ent->waterlevel = 3;
  224. }
  225.  
  226.  
  227. void M_WorldEffects (edict_t *ent)
  228. {
  229.     int        dmg;
  230.  
  231.     if (ent->health > 0)
  232.     {
  233.         if (!(ent->flags & FL_SWIM))
  234.         {
  235.             if (ent->waterlevel < 3)
  236.             {
  237.                 ent->air_finished = level.time + 12;
  238.             }
  239.             else if (ent->air_finished < level.time)
  240.             {    // drown!
  241.                 if (ent->pain_debounce_time < level.time)
  242.                 {
  243.                     dmg = 2 + 2 * floor(level.time - ent->air_finished);
  244.                     if (dmg > 15)
  245.                         dmg = 15;
  246.                     T_Damage (ent, world, world, vec3_origin, ent->s.origin, vec3_origin, dmg, 0, DAMAGE_NO_ARMOR, MOD_WATER);
  247.                     ent->pain_debounce_time = level.time + 1;
  248.                 }
  249.             }
  250.         }
  251.         else
  252.         {
  253.             if (ent->waterlevel > 0)
  254.             {
  255.                 ent->air_finished = level.time + 9;
  256.             }
  257.             else if (ent->air_finished < level.time)
  258.             {    // suffocate!
  259.                 if (ent->pain_debounce_time < level.time)
  260.                 {
  261.                     dmg = 2 + 2 * floor(level.time - ent->air_finished);
  262.                     if (dmg > 15)
  263.                         dmg = 15;
  264.                     T_Damage (ent, world, world, vec3_origin, ent->s.origin, vec3_origin, dmg, 0, DAMAGE_NO_ARMOR, MOD_WATER);
  265.                     ent->pain_debounce_time = level.time + 1;
  266.                 }
  267.             }
  268.         }
  269.     }
  270.     
  271.     if (ent->waterlevel == 0)
  272.     {
  273.         if (ent->flags & FL_INWATER)
  274.         {    
  275.             gi.sound (ent, CHAN_BODY, gi.soundindex("player/watr_out.wav"), 1, ATTN_NORM, 0);
  276.             ent->flags &= ~FL_INWATER;
  277.         }
  278.         return;
  279.     }
  280.  
  281.     if ((ent->watertype & CONTENTS_LAVA) && !(ent->flags & FL_IMMUNE_LAVA))
  282.     {
  283.         if (ent->damage_debounce_time < level.time)
  284.         {
  285.             ent->damage_debounce_time = level.time + 0.2;
  286.             T_Damage (ent, world, world, vec3_origin, ent->s.origin, vec3_origin, 10*ent->waterlevel, 0, 0, MOD_LAVA);
  287.         }
  288.     }
  289.     if ((ent->watertype & CONTENTS_SLIME) && !(ent->flags & FL_IMMUNE_SLIME))
  290.     {
  291.         if (ent->damage_debounce_time < level.time)
  292.         {
  293.             ent->damage_debounce_time = level.time + 1;
  294.             T_Damage (ent, world, world, vec3_origin, ent->s.origin, vec3_origin, 4*ent->waterlevel, 0, 0, MOD_SLIME);
  295.         }
  296.     }
  297.     
  298.     if ( !(ent->flags & FL_INWATER) )
  299.     {    
  300.         if (!(ent->svflags & SVF_DEADMONSTER))
  301.         {
  302.             if (ent->watertype & CONTENTS_LAVA)
  303.                 if (random() <= 0.5)
  304.                     gi.sound (ent, CHAN_BODY, gi.soundindex("player/lava1.wav"), 1, ATTN_NORM, 0);
  305.                 else
  306.                     gi.sound (ent, CHAN_BODY, gi.soundindex("player/lava2.wav"), 1, ATTN_NORM, 0);
  307.             else if (ent->watertype & CONTENTS_SLIME)
  308.                 gi.sound (ent, CHAN_BODY, gi.soundindex("player/watr_in.wav"), 1, ATTN_NORM, 0);
  309.             else if (ent->watertype & CONTENTS_WATER)
  310.                 gi.sound (ent, CHAN_BODY, gi.soundindex("player/watr_in.wav"), 1, ATTN_NORM, 0);
  311.         }
  312.  
  313.         ent->flags |= FL_INWATER;
  314.         ent->damage_debounce_time = 0;
  315.     }
  316. }
  317.  
  318.  
  319. void M_droptofloor (edict_t *ent)
  320. {
  321.     vec3_t        end;
  322.     trace_t        trace;
  323.  
  324.     ent->s.origin[2] += 1;
  325.     VectorCopy (ent->s.origin, end);
  326.     end[2] -= 256;
  327.     
  328.     trace = gi.trace (ent->s.origin, ent->mins, ent->maxs, end, ent, MASK_MONSTERSOLID);
  329.  
  330.     if (trace.fraction == 1 || trace.allsolid)
  331.         return;
  332.  
  333.     VectorCopy (trace.endpos, ent->s.origin);
  334.  
  335.     gi.linkentity (ent);
  336.     M_CheckGround (ent);
  337.     M_CatagorizePosition (ent);
  338. }
  339.  
  340.  
  341. void M_SetEffects (edict_t *ent)
  342. {
  343.     ent->s.effects &= ~(EF_COLOR_SHELL|EF_POWERSCREEN);
  344.     ent->s.renderfx &= ~(RF_SHELL_RED|RF_SHELL_GREEN|RF_SHELL_BLUE);
  345.  
  346.     if (ent->monsterinfo.aiflags & AI_RESURRECTING)
  347.     {
  348.         ent->s.effects |= EF_COLOR_SHELL;
  349.         ent->s.renderfx |= RF_SHELL_BLUE;
  350.     }
  351.     
  352.     if (ent->health <= 0)
  353.         return;
  354.  
  355.     if (ent->powerarmor_time > level.time)
  356.     {
  357.         if (ent->monsterinfo.power_armor_type == POWER_ARMOR_SCREEN)
  358.         {
  359.             ent->s.effects |= EF_POWERSCREEN;
  360.         }
  361.         else if (ent->monsterinfo.power_armor_type == POWER_ARMOR_SHIELD)
  362.         {
  363.             ent->s.effects |= EF_COLOR_SHELL;
  364.             ent->s.renderfx |= RF_SHELL_GREEN;
  365.         }
  366.     }
  367. }
  368.  
  369.  
  370. void M_MoveFrame (edict_t *self)
  371. {
  372.     mmove_t    *move;
  373.     int        index;
  374.  
  375.     move = self->monsterinfo.currentmove;
  376.     self->nextthink = level.time + FRAMETIME;
  377.  
  378.     if ((self->monsterinfo.nextframe) && (self->monsterinfo.nextframe >= move->firstframe) && (self->monsterinfo.nextframe <= move->lastframe))
  379.     {
  380.         self->s.frame = self->monsterinfo.nextframe;
  381.         self->monsterinfo.nextframe = 0;
  382.     }
  383.     else
  384.     {
  385.         if (self->s.frame == move->lastframe)
  386.         {
  387.             if (move->endfunc)
  388.             {
  389.                 move->endfunc (self);
  390.  
  391.                 // regrab move, endfunc is very likely to change it
  392.                 move = self->monsterinfo.currentmove;
  393.  
  394.                 // check for death
  395.                 if (self->svflags & SVF_DEADMONSTER)
  396.                     return;
  397.             }
  398.         }
  399.  
  400.         if (self->s.frame < move->firstframe || self->s.frame > move->lastframe)
  401.         {
  402.             self->monsterinfo.aiflags &= ~AI_HOLD_FRAME;
  403.             self->s.frame = move->firstframe;
  404.         }
  405.         else
  406.         {
  407.             if (!(self->monsterinfo.aiflags & AI_HOLD_FRAME))
  408.             {
  409.                 self->s.frame++;
  410.                 if (self->s.frame > move->lastframe)
  411.                     self->s.frame = move->firstframe;
  412.             }
  413.         }
  414.     }
  415.  
  416.     index = self->s.frame - move->firstframe;
  417.     if (move->frame[index].aifunc)
  418.         if (!(self->monsterinfo.aiflags & AI_HOLD_FRAME))
  419.             move->frame[index].aifunc (self, move->frame[index].dist * self->monsterinfo.scale);
  420.         else
  421.             move->frame[index].aifunc (self, 0);
  422.  
  423.     if (move->frame[index].thinkfunc)
  424.         move->frame[index].thinkfunc (self);
  425. }
  426.  
  427.  
  428. void monster_think (edict_t *self)
  429. {
  430.     M_MoveFrame (self);
  431.     if (self->linkcount != self->monsterinfo.linkcount)
  432.     {
  433.         self->monsterinfo.linkcount = self->linkcount;
  434.         M_CheckGround (self);
  435.     }
  436.     M_CatagorizePosition (self);
  437.     M_WorldEffects (self);
  438.     M_SetEffects (self);
  439. }
  440.  
  441.  
  442. /*
  443. ================
  444. monster_use
  445.  
  446. Using a monster makes it angry at the current activator
  447. ================
  448. */
  449. void monster_use (edict_t *self, edict_t *other, edict_t *activator)
  450. {
  451.     if (self->enemy)
  452.         return;
  453.     if (self->health <= 0)
  454.         return;
  455.     if (activator->flags & FL_NOTARGET)
  456.         return;
  457.     if (!(activator->client) && !(activator->monsterinfo.aiflags & AI_GOOD_GUY))
  458.         return;
  459.     
  460. // delay reaction so if the monster is teleported, its sound is still heard
  461.     self->enemy = activator;
  462.     FoundTarget (self);
  463. }
  464.  
  465.  
  466. void monster_start_go (edict_t *self);
  467.  
  468.  
  469. void monster_triggered_spawn (edict_t *self)
  470. {
  471.     self->s.origin[2] += 1;
  472.     KillBox (self);
  473.  
  474.     self->solid = SOLID_BBOX;
  475.     self->movetype = MOVETYPE_STEP;
  476.     self->svflags &= ~SVF_NOCLIENT;
  477.     self->air_finished = level.time + 12;
  478.     gi.linkentity (self);
  479.  
  480.     monster_start_go (self);
  481.  
  482.     if (self->enemy && !(self->spawnflags & 1) && !(self->enemy->flags & FL_NOTARGET))
  483.     {
  484.         FoundTarget (self);
  485.     }
  486.     else
  487.     {
  488.         self->enemy = NULL;
  489.     }
  490. }
  491.  
  492. void monster_triggered_spawn_use (edict_t *self, edict_t *other, edict_t *activator)
  493. {
  494.     // we have a one frame delay here so we don't telefrag the guy who activated us
  495.     self->think = monster_triggered_spawn;
  496.     self->nextthink = level.time + FRAMETIME;
  497.     if (activator->client)
  498.         self->enemy = activator;
  499.     self->use = monster_use;
  500. }
  501.  
  502. void monster_triggered_start (edict_t *self)
  503. {
  504.     self->solid = SOLID_NOT;
  505.     self->movetype = MOVETYPE_NONE;
  506.     self->svflags |= SVF_NOCLIENT;
  507.     self->nextthink = 0;
  508.     self->use = monster_triggered_spawn_use;
  509. }
  510.  
  511.  
  512. /*
  513. ================
  514. monster_death_use
  515.  
  516. When a monster dies, it fires all of its targets with the current
  517. enemy as activator.
  518. ================
  519. */
  520. void monster_death_use (edict_t *self)
  521. {
  522.     self->flags &= ~(FL_FLY|FL_SWIM);
  523.     self->monsterinfo.aiflags &= AI_GOOD_GUY;
  524.  
  525.     if (self->item)
  526.     {
  527.         Drop_Item (self, self->item);
  528.         self->item = NULL;
  529.     }
  530.  
  531.     if (self->deathtarget)
  532.         self->target = self->deathtarget;
  533.  
  534.     if (!self->target)
  535.         return;
  536.  
  537.     G_UseTargets (self, self->enemy);
  538. }
  539.  
  540.  
  541. //============================================================================
  542.  
  543. qboolean monster_start (edict_t *self)
  544. {
  545.     if (deathmatch->value)
  546.     {
  547.         G_FreeEdict (self);
  548.         return false;
  549.     }
  550.  
  551.     if ((self->spawnflags & 4) && !(self->monsterinfo.aiflags & AI_GOOD_GUY))
  552.     {
  553.         self->spawnflags &= ~4;
  554.         self->spawnflags |= 1;
  555. //        gi.dprintf("fixed spawnflags on %s at %s\n", self->classname, vtos(self->s.origin));
  556.     }
  557.  
  558.     if (!(self->monsterinfo.aiflags & AI_GOOD_GUY))
  559.         level.total_monsters++;
  560.  
  561.     self->nextthink = level.time + FRAMETIME;
  562.     self->svflags |= SVF_MONSTER;
  563.     self->s.renderfx |= RF_FRAMELERP;
  564.     self->takedamage = DAMAGE_AIM;
  565.     self->air_finished = level.time + 12;
  566.     self->use = monster_use;
  567.     self->max_health = self->health;
  568.     self->clipmask = MASK_MONSTERSOLID;
  569.  
  570.     self->s.skinnum = 0;
  571.     self->deadflag = DEAD_NO;
  572.     self->svflags &= ~SVF_DEADMONSTER;
  573.  
  574.     if (!self->monsterinfo.checkattack)
  575.         self->monsterinfo.checkattack = M_CheckAttack;
  576.     VectorCopy (self->s.origin, self->s.old_origin);
  577.  
  578.     if (st.item)
  579.     {
  580.         self->item = FindItemByClassname (st.item);
  581.         if (!self->item)
  582.             gi.dprintf("%s at %s has bad item: %s\n", self->classname, vtos(self->s.origin), st.item);
  583.     }
  584.  
  585.     // randomize what frame they start on
  586.     if (self->monsterinfo.currentmove)
  587.         self->s.frame = self->monsterinfo.currentmove->firstframe + (rand() % (self->monsterinfo.currentmove->lastframe - self->monsterinfo.currentmove->firstframe + 1));
  588.  
  589.     return true;
  590. }
  591.  
  592. void monster_start_go (edict_t *self)
  593. {
  594.     vec3_t    v;
  595.  
  596.     if (self->health <= 0)
  597.         return;
  598.  
  599.     // check for target to combat_point and change to combattarget
  600.     if (self->target)
  601.     {
  602.         qboolean    notcombat;
  603.         qboolean    fixup;
  604.         edict_t        *target;
  605.  
  606.         target = NULL;
  607.         notcombat = false;
  608.         fixup = false;
  609.         while ((target = G_Find (target, FOFS(targetname), self->target)) != NULL)
  610.         {
  611.             if (strcmp(target->classname, "point_combat") == 0)
  612.             {
  613.                 self->combattarget = self->target;
  614.                 fixup = true;
  615.             }
  616.             else
  617.             {
  618.                 notcombat = true;
  619.             }
  620.         }
  621.         if (notcombat && self->combattarget)
  622.             gi.dprintf("%s at %s has target with mixed types\n", self->classname, vtos(self->s.origin));
  623.         if (fixup)
  624.             self->target = NULL;
  625.     }
  626.  
  627.     // validate combattarget
  628.     if (self->combattarget)
  629.     {
  630.         edict_t        *target;
  631.  
  632.         target = NULL;
  633.         while ((target = G_Find (target, FOFS(targetname), self->combattarget)) != NULL)
  634.         {
  635.             if (strcmp(target->classname, "point_combat") != 0)
  636.             {
  637.                 gi.dprintf("%s at (%i %i %i) has a bad combattarget %s : %s at (%i %i %i)\n",
  638.                     self->classname, (int)self->s.origin[0], (int)self->s.origin[1], (int)self->s.origin[2],
  639.                     self->combattarget, target->classname, (int)target->s.origin[0], (int)target->s.origin[1],
  640.                     (int)target->s.origin[2]);
  641.             }
  642.         }
  643.     }
  644.  
  645.     if (self->target)
  646.     {
  647.         self->goalentity = self->movetarget = G_PickTarget(self->target);
  648.         if (!self->movetarget)
  649.         {
  650.             gi.dprintf ("%s can't find target %s at %s\n", self->classname, self->target, vtos(self->s.origin));
  651.             self->target = NULL;
  652.             self->monsterinfo.pausetime = 100000000;
  653.             self->monsterinfo.stand (self);
  654.         }
  655.         else if (strcmp (self->movetarget->classname, "path_corner") == 0)
  656.         {
  657.             VectorSubtract (self->goalentity->s.origin, self->s.origin, v);
  658.             self->ideal_yaw = self->s.angles[YAW] = vectoyaw(v);
  659.             self->monsterinfo.walk (self);
  660.             self->target = NULL;
  661.         }
  662.         else
  663.         {
  664.             self->goalentity = self->movetarget = NULL;
  665.             self->monsterinfo.pausetime = 100000000;
  666.             self->monsterinfo.stand (self);
  667.         }
  668.     }
  669.     else
  670.     {
  671.         self->monsterinfo.pausetime = 100000000;
  672.         self->monsterinfo.stand (self);
  673.     }
  674.  
  675.     self->think = monster_think;
  676.     self->nextthink = level.time + FRAMETIME;
  677. }
  678.  
  679.  
  680. void walkmonster_start_go (edict_t *self)
  681. {
  682.     if (!(self->spawnflags & 2) && level.time < 1)
  683.     {
  684.         M_droptofloor (self);
  685.  
  686.         if (self->groundentity)
  687.             if (!M_walkmove (self, 0, 0))
  688.                 gi.dprintf ("%s in solid at %s\n", self->classname, vtos(self->s.origin));
  689.     }
  690.     
  691.     if (!self->yaw_speed)
  692.         self->yaw_speed = 20;
  693.     self->viewheight = 25;
  694.  
  695.     monster_start_go (self);
  696.  
  697.     if (self->spawnflags & 2)
  698.         monster_triggered_start (self);
  699. }
  700.  
  701. void walkmonster_start (edict_t *self)
  702. {
  703.     self->think = walkmonster_start_go;
  704.     monster_start (self);
  705. }
  706.  
  707.  
  708. void flymonster_start_go (edict_t *self)
  709. {
  710.     if (!M_walkmove (self, 0, 0))
  711.         gi.dprintf ("%s in solid at %s\n", self->classname, vtos(self->s.origin));
  712.  
  713.     if (!self->yaw_speed)
  714.         self->yaw_speed = 10;
  715.     self->viewheight = 25;
  716.  
  717.     monster_start_go (self);
  718.  
  719.     if (self->spawnflags & 2)
  720.         monster_triggered_start (self);
  721. }
  722.  
  723.  
  724. void flymonster_start (edict_t *self)
  725. {
  726.     self->flags |= FL_FLY;
  727.     self->think = flymonster_start_go;
  728.     monster_start (self);
  729. }
  730.  
  731.  
  732. void swimmonster_start_go (edict_t *self)
  733. {
  734.     if (!self->yaw_speed)
  735.         self->yaw_speed = 10;
  736.     self->viewheight = 10;
  737.  
  738.     monster_start_go (self);
  739.  
  740.     if (self->spawnflags & 2)
  741.         monster_triggered_start (self);
  742. }
  743.  
  744. void swimmonster_start (edict_t *self)
  745. {
  746.     self->flags |= FL_SWIM;
  747.     self->think = swimmonster_start_go;
  748.     monster_start (self);
  749. }
  750.